﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PerfAnalyzerLib;

namespace UnitTests
{
	class GeneratorCounter
	{
		/// <summary>
		/// Generate an array filled with the same value.
		/// </summary>
		/// <param name="staticValue">Value to fill the array with.</param>
		/// <param name="arraySize">Size of the array.</param>
		/// <returns></returns>
		public static double[] GenerateStaticArray(double staticValue, int arraySize)
		{
			var array = new double[arraySize];
			
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = staticValue;
			}

			return array;
		}

		/// <summary>
		/// Generate static counter.
		/// </summary>
		/// <param name="name">Counter name.</param>
		/// <param name="staticValue">Value of the counter.</param>
		/// <param name="arraySize">Number of samples in the counter.</param>
		/// <returns></returns>
		public static Counter GanarateStaticCounter(string name, double staticValue, int arraySize)
		{
			var counter = new Counter(name) {Values = GenerateStaticArray(staticValue, arraySize)};
			return counter;
		}

		/// <summary>
		/// Generate an incremental counter.
		/// </summary>
		/// <param name="name">Counter name.</param>
		/// <param name="initialValue">First value of the counter.</param>
		/// <param name="arraySize">Number of samples in the counter.</param>
		/// <returns></returns>
		public static Counter GenerateIncrementalCounter(string name, double initialValue, int arraySize)
		{
			var counter = new Counter(name);
			var values = new double[arraySize];

			double currentValue = initialValue;

			for (int i = 0; i < values.Length; i++)
			{
				values[i] = currentValue++;
			}

			counter.Values = values;

			return counter;
		}
	}
}
